﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IntfSetting.FrmIntf
{
    public partial class FrmFreStep3 : Form
    {
        public FrmFreStep3(string StartTime,string EndTime,int kind)
        {
            InitializeComponent();
            strTime = StartTime;
            endTime = EndTime;

            if (kind == 1)
            {
                this.label2.Visible = true;
                this.dateTimePicker2.Visible = true;
            }
        }

        public string strTime = string.Empty;
        public string endTime = string.Empty;

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.dateTimePicker1.Value == DateTime.MinValue)
            {
                MessageBox.Show("请设置开始时间！");
                dateTimePicker1.Focus();
                return;
            }
            
            if (this.dateTimePicker2.Visible)
            {
                if (this.dateTimePicker2.Value == DateTime.MinValue)
                {
                    MessageBox.Show("请设置结束时间！");
                    dateTimePicker2.Focus();
                    return;
                }

                if (this.dateTimePicker2.Value.CompareTo(this.dateTimePicker1.Value) <= 0)
                {
                    MessageBox.Show("结束时间必须大于开始时间！");
                    dateTimePicker2.Focus();
                    return;

                }
            }

            strTime = this.dateTimePicker1.Text;
            endTime = this.dateTimePicker2.Text;
            this.DialogResult = DialogResult.OK;
            this.Dispose();


            
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void FrmFreStep3_Load(object sender, EventArgs e)
        {
            if (!strTime.Equals(string.Empty))
            {
                this.dateTimePicker1.Text = strTime;     
            }
        }


    }
}
